package com.zdj.presentation.base;

import android.content.Intent;
import android.databinding.BaseObservable;
import android.os.Bundle;

import com.zdj.presentation.helpers.ConstantsHelper;
import com.zdj.presentation.mappers.IEntity2Model;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Created by dengjie zhang on 2016/3/24.
 */

public abstract class BaseViewModel<T extends BaseActivity> extends BaseObservable {

    protected final String TAG = getClass().getSimpleName();

    protected T t;

    protected IEntity2Model mapper;

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.SOURCE)
    protected @interface Command {
    }

    @Target(ElementType.METHOD)
    @Retention(RetentionPolicy.SOURCE)
    protected @interface BindView {
    }


    public BaseViewModel(T t) {
        this.t = t;
    }


    protected void toActivity(Class clz) {
        Intent intent = new Intent(t, clz);
        t.startActivity(intent);
    }

    protected void toActivity(Class clz, Bundle bundle){
        Intent intent = new Intent(t, clz);
        intent.putExtra(ConstantsHelper.BUNDLE,bundle);
        t.startActivity(intent);
    }
}
